<template>
  <div class="home">
    <el-container style="height: 100vh; border: 1px solid #eee">
      <el-aside
        width="200px"
        style="background-color: rgb(238, 241, 246); height: 100vh"
      >
      <common-aside/>
      </el-aside>
      <el-container>
          <el-header
          style="
            border-bottom: 1px solid #ccc;
            height: 62px;        
            background-color: #333;
          ">
          <common-header :user="user"/>
         <!--   text-align: right;
            font-size: 12px;
            border-bottom: 1px solid #ccc;
            line-height: 60px; -->
          </el-header>
        <el-main>
         <router-view @refreshUser="load"></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import CommonAside from '@/components/CommonAside.vue';
import CommonHeader from '@/components/CommonHeader.vue';
import UserView from '@/views/UserView.vue';
import request from "@/utils/request";
export default {
  name:'Home',
  data() {
    return {
    
     user: {},
     
    };
  },
   components:{
    CommonAside,
    CommonHeader,
    UserView
  }
  ,
  created(){
    this.load()
  },
   methods:{
       load() {
     /*  request.get("user/person/" + this.user.username).then((res) => {
        this.form = res.data;
      }); */
   /*    let res= await request.get("user/person/" + this.user.username);
      console.log(res);
      this.form = res.data;
      return res.data; */
      let username=localStorage.getItem("user")?JSON.parse(localStorage.getItem("user")).username:{};
      return  this.request.get("user/person/"+username).then(res=>{
         //重新赋值
          this.user=res.data
          console.log(this.user)
      })
    },
   },
 
 
};
</script>
<style scoped>
.title {
  display: flex;
  margin: 0 auto;
}
 
</style>
